package com.aube.model;

import com.huyn.baseframework.model.VideoPlayModel;
import com.huyn.baseframework.utils.StringUtils;

import java.io.Serializable;

/**
 * Created by huyaonan on 16/7/5.
 */
public class VrItem implements Serializable {

    public String type;
    public String rid;
    public int startSeconds;
    public int endSeconds;
    public String title;
    public String tlDesc;
    public String thumbnailCard;
    public VrItemDetail detail;

    public int preloadSeconds;

    public boolean isLegal() {
        if(detail != null) {
            return detail.isLegal();
        }
        return false;
    }

    public VideoPlayModel getVideo() {
        if(detail == null)
            return null;
        return detail.getVideo();
    }

    public String getAngleX() {
        if(detail != null)
            return detail.leftRightAngle;
        return "";
    }

    public String getAngleY() {
        if(detail != null)
            return detail.updownAngle;
        return "";
    }

    public float[] getAngleXY() {
        float[] result = new float[2];
        if(detail != null) {
            if(StringUtils.isNotBlank(detail.leftRightAngle))
                result[0] = Float.parseFloat(detail.leftRightAngle);
            else
                result[0] = 0;

            if(StringUtils.isNotBlank(detail.updownAngle))
                result[1] = Float.parseFloat(detail.updownAngle);
            else
                result[1] = 0;
        } else {
            result[0] = 0;
            result[1] = 0;
        }
        return result;
    }

}
